import { BaseViewModel, BasePageInfo } from '@ohos/lib_common'
import { API } from '../../../common/constants/api'

// 路况信息 item
export interface TrafficStatusItem {
  forumId: string
  topicId: string
  postUserId: string
  content: string
  icon: string
  lnglat: string
  address: string
  postUserNickname: string
  postUserAvatar: string
  phone: string
  postTime: string
  topicName: string
  goodClickCount: number
  commentCount: number
  trunCount: number
  resourceType: number
  resourceUrl: string
  createTime: string
  endTime: string
  integral: number
  topicDetailVO: {
    topicId: string
    topicCategoryId: string
    nickname: string
    topicName: string
    topicAvatar: string
    remark: string
    follow: number
    focusFlag: boolean
    postFlag: boolean
    forumCount: number
    avatar: string[]
    forumType: boolean
    statusFlag: boolean
    startTime: string
    delFlag: boolean
  }
  trafficType: number
  commentFlag: number
  replyFlag: number
  goodClickFlag: number
  trunFlag: number
  headFrameUrl: string
  thumbList: [],
  ipPosition: string
  ipPositionArea: string
  tag: {
    id: string
    name: string
    type: number
    icon: string
  }[]
}

// 路况信息数据
interface TrafficStatusData extends BasePageInfo {
  records: TrafficStatusItem[]
}

// 请求数据
export class TrafficStatusDataModal extends BaseViewModel {
  async getTrafficStatusData() {
    const res = await this.get<TrafficStatusData>({ url: API.TRAFFIC_STATUS })
    return res;
  }
}

export const trafficStatusDataModal = new TrafficStatusDataModal()